﻿using System;
using System.Web.UI;
using MyWeb.Business;

namespace MyWeb.Admin.Usercontrols
{
    public partial class ucOrderView : UserControl
    {
        private readonly OrderService _orderService = new OrderService();
        private readonly UserService _userService = new UserService();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
                LoadDdl();
            }
        }

        private void BindGrid()
        {
            gvData.DataSource = _orderService.Order_GetByAll();
            gvData.DataBind();
        }

        private void LoadDdl()
        {
            ddlUser.DataSource = _userService.User_GetByAll();
            ddlUser.DataTextField = "name";
            ddlUser.DataValueField = "id";
            ddlUser.DataBind();
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {

        }

        protected void gvData_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
        {
            gvData.PageIndex = e.NewPageIndex;
            BindGrid();
        }
    }
}